/**
 * 定义一个泛型接口，要求满足所有的服务器返回的数据
 */

interface ApiRes<T> {
  code: number
  data: T
  message: string
}

interface User {
  nickname: string
  avatar: string
}

// 获取的返回用户信息的数据
const res: ApiRes<User> = {
  code: 200,
  data: {
    nickname: 'zhangsan',
    avatar: 'http://www.baid.com.png'
  },
  message: '获取个人信息'
}

console.log('---res---', res)

interface Swiper {
  bannerid: string
  img: string
}

const res2: ApiRes<Swiper[]> = {
  code: 200,
  data: [
    {
      bannerid: '1001',
      img: 'http://www.bpng'
    },
    {
      bannerid: '1001',
      img: 'http://www.bpng'
    },
    {
      bannerid: '1001',
      img: 'http://www.bpng'
    },
    {
      bannerid: '1001',
      img: 'http://www.bpng'
    }
  ],
  message: '查看轮播图'
}

console.log('---res2---', res2)

// es5、es6中泛型接口它是怎么使用的
let persons: Array<string> = ['蔡嘉奕', '张文清', '黄日汉', '邹思敏']
persons.forEach((item, index, array) => {})

let yanzhi: Array<number> = [100, 100, 100, 100]
yanzhi.forEach((item, index, array) => {})
yanzhi.find(item => {})

export {}
